import { defineStore } from "pinia";

const useBaseLowCode = defineStore("lowCode", {
  state: () => {
    return {
      componentGrouped: [
        {
          title: "基础组件",
          componentLists: [
            // {
            //   type: "head",
            //   name: "标题",
            //   id: parseInt( new Date().getTime() /10000 ),
            //   dataField: {
            //     bgColor: "#e43130",
            //     bgImg: "",
            //     bgType: 0,
            //     category: "",
            //     description: "",
            //     gmtStart: "",
            //     textColor: "#ffffff",
            //     title: "测试",
            //   },
            // },
            {
              type: "title",
              name: "标题文本",
              icon:"i-titleText.png",
              id: parseInt(new Date().getTime() / 10000),
              dataField: {
                title: "测试",
                titleSize: "12",
                describe: "",
                position: "1",
                more: false,
              },
            },
            {
              type: "search",
              name: "搜索",
              icon:"i-searchBar.png",
              id: parseInt(new Date().getTime() / 10000),
              dataField: {},
            },
            {
              type: "goods",
              name: "商品列表",
              icon:"i-productList.png",
              id: parseInt(new Date().getTime() / 10000),
              dataField: {
                styleValue: "1",
                goodsIndex: 0,
                item: {
                  pic: "",
                  title: "",
                  price: "",
                },
                lists: [
                  {
                    pic: "https://h2.appsimg.com/a.appsimg.com/upload/merchandise/pdcvis/108668/2023/0727/161/26b80d92-dfe0-4f55-b17e-e9bfa821f605_218x218_90.jpg",
                    title: "肌本清源洁面乳120g温和清洁洗面奶爆款不紧",
                    price: "20.58",
                  },
                  {
                    pic: "https://h2.appsimg.com/a.appsimg.com/upload/merchandise/pdcvis/108668/2023/0727/161/26b80d92-dfe0-4f55-b17e-e9bfa821f605_218x218_90.jpg",
                    title: "肌本清和清洁洗面奶爆款不紧",
                    price: "220.58",
                  },
                ],
              },
            },
            {
              type: "tabbar",
              name: "底部导航",
              id: parseInt(new Date().getTime() / 10000),
              dataField: {
                list: [
                  {
                    pagePath: "pages/index/index",
                    iconPath: "/static/images/tabbar/home.png",
                    selectedIconPath: "/static/images/tabbar/home-selected.png",
                  },
                  {
                    pagePath: "pages/basket/basket",
                    iconPath: "/static/images/tabbar/shopping.png",
                    selectedIconPath:
                      "/static/images/tabbar/shopping-selected.png",
                  },
                  {
                    pagePath: "pages/order-list/order-list",
                    iconPath: "/static/images/tabbar/order.png",
                    selectedIconPath:
                      "/static/images/tabbar/order-selected.png",
                  },
                  {
                    pagePath: "pages/user/user",
                    iconPath: "/static/images/tabbar/my.png",
                    selectedIconPath: "/static/images/tabbar/my-selected.png",
                  },
                ],
              },
            },
            {
              type: "pictureAd",
              name: "图片广告",
              icon:"i-pictureAd.png",
              id: parseInt(new Date().getTime() / 10000),
              dataField: {},
            },
          ],
        },
      ],
      lowCodeDatas: [
        {
          type: "head",
          name: "标题",
          id: 170839998,
          dataField: {
            bgColor: "#e43130",
            bgImg: "",
            bgType: 0,
            category: "",
            description: "",
            gmtStart: "",
            textColor: "#ffffff",
            title: "测试",
          },
        },
      ],
      componentsConfig: {},
    };
  },
  getters: {
    getLowCodeDatas(state) {
      return state.lowCodeDatas;
    },
    getComponentsConfig(state) {
      return state.componentsConfig;
    },
  },
  actions: {
    addComponentGrouped(value) {
      this.componentGrouped.push(value);
    },
    setComponentsConfig(value) {
      this.componentsConfig = value;
    },
    setLowCodeDatas(value) {
      this.lowCodeDatas.push(value);
    },
  },
});

export default useBaseLowCode;
